package form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.validator.ValidatorForm;

public class RegistrationForm extends ValidatorForm {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -6852649243439568417L;
	
	private int id = -1;
	private String email;
	private String password;
	private int tipoUsuario;
	private int age;
	private String signUpDate;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getTipoUsuario() {
		return tipoUsuario;
	}

	public void setTipoUsuario(int tipoUsuario) {
		this.tipoUsuario = tipoUsuario;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getSignUpDate() {
		return signUpDate;
	}

	public void setSignUpDate(String signUpDate) {
		this.signUpDate = signUpDate;
	}

	public ActionErrors validateOLD(ActionMapping mapping, HttpServletRequest request) {
		
		ActionErrors errors = new ActionErrors();
		
	    String email = getEmail(); // request.getParameter("email");
	    String password = getPassword(); // request.getParameter("password");
	    if ((email == null) ||
	        (email.trim().length() < 3) ||
	        (email.indexOf("@") == -1)) {
	      
	    	errors.add("email", new ActionMessage("email.format"));
	    	
	    } 
	    if ((password == null) ||
	               (password.trim().length() < 8)) {
	      
	    	errors.add("password", new ActionMessage("password.length"));
	    } 
			   
		return errors;
	}
	
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		// TODO Auto-generated method stub
//		super.reset(mapping, request);
		
		setPassword(null);
	}

}
